////////////////////////////////////////////////////////////////////////////////


*Appendix B: Predictive content of subjective job security


////////////////////////////////////////////////////////////////////////////////

**PART ONE: US

cd "$usdata"

use "clean/hrs_clean.dta", clear

rename insecurity insecure

logit unemp L.insecure L.parttime L.age L.age_squared L.male L.union L.nonwhite L.immigrant L.uni L.marital Lb2002.year if participant==1 [pw=wtresp], vce(robust)
	margins, eydx(L.insecure) post
	estimates store hrs
	matrix define b = r(b)
	scalar define a = b[1,1]

	di "Elasticity of unemployment w.r.t feeling insecure: `=a'"
	
**PART TWO: UK

cd "$ukdata"

use "clean/uk_linear_reverse.dta", clear
	drop if year>2009
	bys pid year: gen i=_N
	drop if i>1
	drop i
	replace cjsbgy4=. if cjsbgy4<0
	replace cjsbgd=. if cjsbgd<0
	replace cjsbgm=. if cjsbgm<0
	xtset pid year
	gen unemp=1 if cjsbgy4+(cjsbgm/12)+(cjsbgd/365)>L.year+(L.doim/12)+(L.doid/365)&cjsbgd!=.
	replace unemp=0 if cjsbgy4+(cjsbgm/12)+(cjsbgd/365)<L.year+(L.doim/12)+(L.doid/365)&cjsbgd!=.
	gen insecure=1 if bhps_security<=3
	replace insecure=0 if bhps_security>3

logit unemp L.insecure L.temp L.parttime L.age L.age_squared L.jobtenure L.semp_boss L.semp L.union L.male Lb1.marital L.uni L.immigrant L.nonwhite Lb0.isco Lb2001.year [pw=relative_xw], vce(robust)
	margins, eydx(L.insecure) post
	estimates store bhps
	matrix define b = r(b)
	scalar define a = b[1,1]

	di "Semi-elasticity of unemployment w.r.t feeling insecure: `=a'"

	
**PART THREE: Germany

cd "$germanydata"

use "clean/soep_clean.dta", clear
	xtset pid year
	replace insecure=. if employed==0
	gen unemp=1 if job_change==1|employed==0
	replace unemp=0 if employed==1|job_change==0
	
logit unemp L.insecure Lb2001.year L.temp L.parttime L.semp L.marginal L.immigrant Lb3.marital Lb1.isco L.male L.age L.age_squared L.uni [pw=xw], vce(robust)
	margins, eydx(L.insecure) post
	estimates store soep
	matrix define b = r(b)
	scalar define a = b[1,1]

	di "Semi-elasticity of unemployment w.r.t feeling insecure: `=a'"
	
*Table B.1: elasticities of unemployment w.r.t. insecurity
cd "$tables"

esttab hrs bhps soep using "predictive_content.tex", nonumber se replace booktab mlabels("HRS" "BHPS/UKHLS" "SOEP") coeflabels(L.insecure "Insecurity") title("Elasticity/semi-elasticity of unemployment")
